import {
  GoodsParams,
  GoodsPageParams,
  GoodsListGetResultModel,
  GoodsPageListGetResultModel,
} from './model/GoodsModel';

import { defHttp } from '/@/utils/http/axios';

enum Api {
  GoodsList = '/system/getGoodsList',
  GoodsPageList = '/system/getGoodsByPage',
  SaveOrUpdateGoods = '/system/saveOrUpdateGoods',
}

export const getGoodsList = (params: GoodsParams) =>
  defHttp.get<GoodsListGetResultModel>({ url: Api.GoodsList, params });

export const getGoodsListByPage = (params?: GoodsPageParams) =>
  defHttp.get<GoodsPageListGetResultModel>({ url: Api.GoodsPageList, params });

export const saveOrUpdateGoods = (params?: GoodsParams) =>
  defHttp.post({ url: Api.SaveOrUpdateGoods, params }, { errorMessageMode: 'modal' });
